home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 62
/
Volume 62 - JOGO DISK .iso
/
Games
/
penguin_dinner.swf
/
scripts
/
__Packages
/
com
/
potapenko
/
util
/
MovieClipUtil.as
Wrap
Text File
|
2008-03-17
|
8KB
|
321 lines
class com.potapenko.util.MovieClipUtil extends Object
{
function MovieClipUtil(movie)
{
super();
this.movie = movie;
}
function moveTo(x, y)
{
this.movie._x = x;
this.movie._y = y;
return this;
}
function moveBy(xo, yo)
{
this.movie._x += xo;
this.movie._y += yo;
return this;
}
function size(w, h)
{
if(w != null && w != 0)
{
this.movie._width = w;
}
if(h != null && h != 0)
{
this.movie._height = h;
}
return this;
}
function scale(s)
{
this.movie._xscale = this.movie._yscale = s;
return this;
}
function scaleTo(xscale, yscale)
{
if(xscale != null && xscale != 0)
{
this.movie._xscale = xscale;
}
if(yscale != null && yscale != 0)
{
this.movie._yscale = yscale;
}
return this;
}
function scaleBy(sc)
{
this.movie._xscale *= sc;
this.movie._yscale *= sc;
return this;
}
function rotateBy(ri)
{
this.movie._rotation += ri;
return this;
}
function hide()
{
this.movie._visible = false;
return this;
}
function show()
{
this.movie._visible = true;
return this;
}
function visInvert()
{
this.movie._visible = !this.movie._visible;
return this;
}
function flipV()
{
this.movie._xscale *= -1;
return this;
}
function flipH()
{
this.movie._yscale *= -1;
return this;
}
function playOffset(po)
{
this.movie.gotoAndPlay(this.movie._currentframe + po);
return this;
}
function childs()
{
var _loc2_ = new Array();
for(var _loc3_ in this.movie)
{
if(typeof this.movie[_loc3_] == "movieclip" && this.movie[_loc3_]._parent == this.movie)
{
_loc2_.push(this.movie[_loc3_]);
}
}
return _loc2_;
}
function getAllChilds()
{
var _loc5_ = arguments[0];
var _loc7_ = arguments[1];
var _loc9_ = false;
if(_loc5_ == null)
{
_loc5_ = new Array();
_loc9_ = true;
}
else
{
_loc5_.push(this);
}
this.movie.__tested_marker = true;
var _loc3_ = undefined;
var _loc6_ = undefined;
for(var _loc8_ in this.movie)
{
_loc3_ = this.movie[_loc8_];
if(typeof _loc3_ == "movieclip" && _loc3_.__tested_marker == undefined && _loc3_._parent == this.movie)
{
_loc6_ = new com.potapenko.util.MovieClipUtil(_loc3_);
_loc6_.getAllChilds(_loc5_,_loc7_);
}
}
if(_loc9_)
{
var _loc4_ = 0;
while(_loc4_ < _loc5_.length)
{
delete _loc5_[_loc4_].__tested_marker;
_loc4_ = _loc4_ + 1;
}
}
return _loc5_;
}
function copy(fromClip, paramArray)
{
if(paramArray == null)
{
paramArray = new Array("_width","_height","_x","_y","_alpha","_rotation");
}
var _loc5_ = fromClip._rotation;
fromClip._rotation = 0;
var _loc6_ = this.movie._rotation;
this.movie._rotation = 0;
var _loc2_ = 0;
while(_loc2_ < paramArray.length)
{
this.movie[paramArray[_loc2_]] = fromClip[paramArray[_loc2_]];
_loc2_ = _loc2_ + 1;
}
fromClip._rotation = _loc5_;
this.movie._rotation = _loc5_;
return this;
}
function copyColor(fromClip)
{
new Color(this.movie).setTransform(new Color(fromClip).getTransform());
return this;
}
function top()
{
if(this.movie._parent != _root)
{
return this.movie._parent.top();
}
return this.movie;
}
function newSound(id, volume, loop)
{
this.movie.mySound = new Sound();
this.movie.mySound.attachSound(id);
this.movie.mySound.setVolume(volume || 100);
this.movie.mySound.start(0,loop || 1);
return this;
}
function stopSound(id, volume, loop)
{
this.movie.mySound.stop();
return this;
}
function localToLocal(toMcCoordinats, point)
{
this.movie.localToGlobal(point);
toMcCoordinats.globalToLocal(point);
}
function align(fromClip, ignoreFromBounds, ignoreMovieBounds)
{
if(fromClip == undefined)
{
fromClip = this.movie._parent;
}
var _loc8_ = fromClip.getBounds(_root);
var _loc7_ = this.movie.getBounds(_root);
var _loc5_ = {x:(_loc8_.xMin + _loc8_.xMax) / 2,y:(_loc8_.yMin + _loc8_.yMax) / 2};
if(fromClip._width == 0 || ignoreFromBounds == true)
{
var _loc9_ = {x:fromClip._x,y:10};
fromClip._parent.localToGlobal(_loc9_);
_loc5_.x = _loc9_.x;
}
if(fromClip._height == 0 || ignoreFromBounds == true)
{
_loc9_ = {x:10,y:fromClip._y};
fromClip._parent.localToGlobal(_loc9_);
_loc5_.y = _loc9_.y;
}
var _loc6_ = {x:(_loc7_.xMin + _loc7_.xMax) / 2,y:(_loc7_.yMin + _loc7_.yMax) / 2};
if(this.movie._width == 0 || ignoreMovieBounds == true)
{
_loc9_ = {x:this.movie._x,y:10};
fromClip._parent.localToGlobal(_loc9_);
_loc6_.x = _loc9_.x;
}
if(this.movie._height == 0 || ignoreMovieBounds == true)
{
_loc9_ = {x:10,y:this.movie._y};
fromClip._parent.localToGlobal(_loc9_);
_loc6_.y = _loc9_.y;
}
this.movie._parent.globalToLocal(_loc5_);
this.movie._parent.globalToLocal(_loc6_);
if(arguments[1] != "v")
{
this.movie._x += _loc5_.x - _loc6_.x;
}
if(arguments[1] != "h")
{
this.movie._y += _loc5_.y - _loc6_.y;
}
return this;
}
function alignH(fromClip)
{
this.movie.align(fromClip,"h");
return this;
}
function alignV(fromClip)
{
this.movie.align(fromClip,"v");
return this;
}
function createRound(name, depth, radius, color)
{
var _loc2_ = this.movie.createEmptyMovieClip(name,depth);
radius = radius / 2 || 2;
_loc2_.lineStyle(radius,color || 0,100);
_loc2_.lineTo(0,0.15);
return _loc2_;
}
function createSqv(name, depth, width, color, center)
{
if(depth == undefined)
{
depth = 2123;
}
if(width == undefined)
{
width = 12;
}
if(center == undefined)
{
center = true;
}
var _loc3_ = this.movie.createEmptyMovieClip(name,depth);
var _loc2_ = 0;
if(center)
{
_loc2_ = (- width) / 2;
}
_loc3_.moveTo(_loc2_,_loc2_);
_loc3_.beginFill(color || 0);
_loc3_.lineTo(width + _loc2_,_loc2_);
_loc3_.lineTo(width + _loc2_,width + _loc2_);
_loc3_.lineTo(_loc2_,width + _loc2_);
_loc3_.lineTo(_loc2_,_loc2_);
_loc3_.endFill();
return _loc3_;
}
function pixelatePosition()
{
var _loc2_ = this.movie.localToGlobal({x:this.movie._x,y:this.movie._y});
this.movie._x -= _loc2_.x % 1;
this.movie._y -= _loc2_.y % 1;
return this;
}
function animToPlace(startA, finishA, steps, currStep, xy)
{
this.movie[xy] = this.inOut(startA,finishA,steps,currStep);
return this;
}
function inOut(startA, finishA, steps, currStep)
{
if(currStep >= steps)
{
return finishA;
}
if(currStep <= 0)
{
return startA;
}
return startA + (finishA - startA) * this.ease(steps * 2,currStep);
}
function ease(steps, curStep)
{
if(steps <= curStep)
{
return 0;
}
if(steps / 2 == curStep)
{
return 1;
}
var _loc1_ = Math.sin(curStep / steps * 180 * 3.141592653589793 / 180);
return _loc1_ * _loc1_ * _loc1_;
}
}